package com.gitee.mars.marsquickframe.controller;

import com.gitee.mars.marsquickframe.request.FavoriteRequest;
import com.gitee.mars.marsquickframe.request.NoteBookRequest;
import com.gitee.mars.marsquickframe.response.result.R;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;

import java.util.Arrays;

import com.gitee.mars.marsquickframe.entity.Favorite;
import com.gitee.mars.marsquickframe.service.IFavoriteService;

/**
 * Favorite 控制层
 *
 * @Author wq
 * @Date 2021-05-04
 **/
@RestController
@RequestMapping("/favorite")
@AllArgsConstructor
public class FavoriteController {

    private final IFavoriteService favoriteService;

    @PostMapping("/add")
    public R add(@RequestBody FavoriteRequest req) {
        favoriteService.add(req);
        return R.success("新增成功");
    }

    @PostMapping("/list")
    public R list(@RequestBody FavoriteRequest request) {
        return R.success(favoriteService.list(request));
    }


    @GetMapping("/delete")
    public R delete(Integer id) {
        favoriteService.delete(id);
        return R.success();
    }

    @PostMapping("/update")
    public R update(@RequestBody FavoriteRequest request) {
        favoriteService.update(request);
        return R.success();
    }

    @GetMapping("/detail")
    public R detail(Integer id) {
        return R.success(favoriteService.detail(id));
    }

}